FROM tomcat:9-jre8-alpine

# 作者信息
MAINTAINER "Virens <loioi@virens.cn>" 

# 定义基础变量
ENV TZ=Asia/Shanghai
ENV JAVA_OPTS -server -Xms256M -Xmx2048M
ENV CATALINA_OPTS -Djava.security.egd=file:/dev/urandom

# 更改系统时区 & 安装字体
RUN apk update && apk add tzdata && apk add ttf-dejavu && rm -rf /var/cache/apk/*
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo '${TZ}' > /etc/timezone

# 清理无用ROOT
RUN rm -rf ${CATALINA_HOME}/webapps/* && mkdir ${CATALINA_HOME}/webapps/ROOT/

# 应用信息
ENV WEBAPP_NAME=virens-spring

# 拷贝应用
COPY ./target/${WEBAPP_NAME} ${CATALINA_HOME}/webapps/ROOT 

# 复制配置及资源文件
COPY ./src/main/docker/tomcat/conf/* ${CATALINA_HOME}/conf/
COPY ./src/main/docker/dubbo/* ${CATALINA_HOME}/webapps/ROOT/WEB-INF/classes/dubbo/
COPY ./src/main/docker/config/* ${CATALINA_HOME}/webapps/ROOT/WEB-INF/classes/config/

# 创建磁盘挂载点
VOLUME ${CATALINA_HOME}/webapps/ROOT/upload
VOLUME ${CATALINA_HOME}/logs
